package com.aaa.controller;

import com.aaa.entity.Userinfo;
import com.aaa.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author ：Teacher陈（86521760@qq.com）
 * @date ：Created in 2022/6/20 9:25
 * @description：
 * @modified By：
 * @version:
 */
@Controller
@RequestMapping("userinfoMVC")
public class UserInfoMVCController  {
    @Autowired
    private  UserInfoService userInfoService;

    @RequestMapping("findAllUser.do")
    public  String findAllUser(HttpSession httpSession){
        System.out.println("请求到达");
        List<Userinfo> userinfoList = userInfoService.findAllUser();
        for (Userinfo userinfo : userinfoList) {
            System.out.println(userinfo.toString());
        }
        httpSession.setAttribute("userinfoList",userinfoList);
        return "aaa";
    }
    @RequestMapping("deleteUserInfo.do")
    public  String deleteUserInfo(Integer userid){
        System.out.println("开始删除了,id:"+userid);
        userInfoService.deleteUserInfoById(userid);
        return "redirect:findAllUser.do";
    }
}
